#!/bin/bash        
echo "Creating a Boolean flow graph, output to png file. "
FILEENDING=".png"
OUTFILE="$2$FILEENDING"

if [ $# -ne 2 ]
then
    echo "Usage: [inputfile] [outputfile without file ending]"
    exit
fi

if [ -f $OUTFILE ]
then
    echo "Output file [$2] already exists"
    echo "Okay to overwrite? (y/n):"
    read answer
    if [ "$answer" = "n" ] || [ "$answer" = "N" ]
    then
      echo "Aborting"
      exit
    fi
fi

./bp2bfg/bp2bfg.byte -i $1 -format dot | dot -Tpng -o $OUTFILE